package lex.explorer;

import java.io.File;
import javax.swing.Icon;
import javax.swing.filechooser.FileView;

import org.lex.explorer.SimpleFileInfo;

/**
 * �����ļ�����Ϣ��������"ˢ��"��ʱ���������ֱ�Ӵ��ļ�ϵͳ�ض���Щ��Ϣ�����������
 * 
 * @author Daniel Liu
 */
public class SimpleFileInfo {
	public static SimpleFileInfo get(FileView view, File file) {
		SimpleFileInfo info = new SimpleFileInfo();
		get(view, file, info);
		return info;
	}

	/**
	 * read <code>file</code> information to <code>info</code>
	 * 
	 * @param file
	 * @param info
	 */
	protected static void get(FileView view, File file, SimpleFileInfo info) {
		info.file = file;
		info.name = view.getName(file);
		info.isFile = file.isFile();
		info.isDirectory = file.isDirectory();
		info.icon = view.getIcon(file);
	}

	public File getFile() {
		return file;
	}

	public boolean isDirectory() {
		return isDirectory;
	}

	public boolean isFile() {
		return isFile;
	}

	public Icon getIcon() {
		return icon;
	}

	public String getName() {
		return name;
	}

	private File file = null;
	private String name = "";
	private boolean isFile = false;
	private boolean isDirectory = false;
	private Icon icon = null;

	/**
	 * this class is immutable, use static factory to create instance
	 */
	protected SimpleFileInfo() {
	}
}
